Repository navigation
Defaults in a TOML file, with user override - #92
Merged
Merged
Conversation
Python 3.10 reached its end of life in October 2026, and 3.11 reads TOML without a further dependency. The tests run on 3.11 and 3.12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two JSON templates held defaults of their own, which every write then
overwrote, and a placeholder part ("Part text here") that a question without
parts was written with. The writer now builds the JSON from the set and its
questions alone, and a question without parts is written with none.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The defaults of the set, the question, every response area and each response type were spread across the classes and the JSON templates. They are now in in2lambda/defaults.toml, which fills in each setting an author leaves unset; a response type's own table comes before the one for every response area. A response type without a default evaluation function needs one from the author. The defaults change: questions are published with the chatbot shown, the set's chatbot is open, and sets are no longer hidden on import. Response areas show a live preview and are included in the PDF, multi-line maths aside, and single-line maths shows its input symbols. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
in2lambda.defaults.override(path), or `in2lambda --defaults path`, lays a TOML file holding only the values to change over in2lambda's defaults. A file that is not valid TOML, or that sets something in2lambda has no default for or a value of the wrong type, is refused and changes nothing. The quickstart says how, and shows in2lambda's defaults.toml as it stands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m-messer
approved these changes
Oct 26, 2026
m-messer
left a comment
Member
There was a problem hiding this comment.
Looks like a good design for setting defaults at runtime.
From some research into UNSET, it uses the sentinel design pattern (https://python-patterns.guide/python/sentinel-object/), as the defaults are set after importing the library with the CLI command --defaults. To make it clearer, you could rename UNSET to FROM_DEFAULTS.
|
|
||
| def _key(name: str) -> str: | ||
| """A field's key in the defaults, e.g. ``_chatbotVisibility`` -> ``chatbot_visibility``.""" | ||
| return re.sub(r"(?<!^)([A-Z])", r"_\1", name.lstrip("_")).lower() |
Member
There was a problem hiding this comment.
This could be made clearer by not using regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defaults have been moved to a single file,
in2lambda/defaults.toml. The abstraction helps manage the package as defaults were previously buried in the code. A user can override any individual default by creating a TOML file of their own. Other cleanups are included in this PR.The PR contains four separate commits that can be reviewed separately. To keep them separate on
main, merge with a merge commit or rebase, not squash.in2lambdacreates every field accommodated by Lambda Feedback, JSON templates are not needed. Further, a placeholder part ("Part text here") that was written for a question with no parts is not needed. The writer now builds the JSON itself, and questions without parts contain no parts in the JSON.defaults.toml. A response type's own table takes precedence over the general[response_area]table.in2lambda.defaults.override(path)orin2lambda --defaults path. A file that isn't valid TOML, or that has an unknown key or a value of the wrong type, is rejected. The quickstart docs has a new section on defaults.Behaviour changes for existing users (for the release notes):
The full list is in commit 3's message.
Tests: all 36 pass, and each commit also passes on its own. The new
tests/test_defaults.pychecks that a user's file changes only what it sets, and that each kind of mistake is refused without changing anything.Message edited significantly by PBJ after being generated with 🤖 Claude Code. Code itself is all by Claude, overseen and reviewed by PBJ.